import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

public class BusRouteQuerySystem extends JFrame {
    private JTextField routeField;
    private JTextArea resultArea;

    public BusRouteQuerySystem() {
        setTitle("公交路线查询系统");
        setSize(400, 300);
        setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        setLocationRelativeTo(null);

        JPanel panel = new JPanel();
        panel.setLayout(new BorderLayout());

        JLabel routeLabel = new JLabel("请输入公交路线：");
        routeField = new JTextField(20);
        JButton queryButton = new JButton("查询");
        resultArea = new JTextArea(10, 30);
        resultArea.setEditable(false);

        panel.add(routeLabel, BorderLayout.NORTH);
        panel.add(routeField, BorderLayout.CENTER);
        panel.add(queryButton, BorderLayout.EAST);
        panel.add(new JScrollPane(resultArea), BorderLayout.SOUTH);

        queryButton.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                String route = routeField.getText();
                // 调用查询公交路线的方法
                String result = queryBusRoute(route);
                resultArea.setText(result);
            }
        });

        add(panel);
        setVisible(true);
    }

    private String queryBusRoute(String route) {
        // 根据输入的公交路线进行查询，返回查询结果
        // 这里只是一个示例，具体的查询逻辑需要根据实际需求进行实现
        return "查询到的公交路线：" + route;
    }

    public static void main(String[] args) {
        new BusRouteQuerySystem();
    }
}